package chatroom;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author Gong
 * @Description
 * @dATE 2022/4/20 10:46
 **/
@WebServlet("/s2")
public class S2 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ServletContext servletContext = this.getServletContext();
        // 第二种方法
        // ServletContext servletContext2 = this.getServletConfig().getServletContext();
        Object name = servletContext.getAttribute("name");
        System.out.println(name);

    }
}